#include <memory>

#include "rclcpp/rclcpp.hpp"
#include "bs_complex/msg/complex_num.hpp"
using std::placeholders::_1;

class ComplexNumSubscriber : public rclcpp::Node
{
public:
  ComplexNumSubscriber()
  : Node("complex_subscriber")
  {
    subscription_ = this->create_subscription<bs_complex::msg::ComplexNum>(
      "complex_num", 10, std::bind(&ComplexNumSubscriber::topic_callback, this, _1)
    );
  }

private:
  rclcpp::Subscription<bs_complex::msg::ComplexNum>::SharedPtr subscription_;

  void topic_callback(const bs_complex::msg::ComplexNum::SharedPtr msg) const
  {
    RCLCPP_INFO(this->get_logger(), "Subscribe: re=%.3f im=%.3f", msg->re, msg->im);
    
  }
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<ComplexNumSubscriber>());
  rclcpp::shutdown();
  return 0;
}